package com.ayoka.ui.mine.collection;

import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.ayoka.R;
import com.ayoka.adapter.MeditationCollectionAdapter;
import com.ayoka.base.BaseRecyclerViewFragment;
import com.ayoka.bean.PagerBean;
import com.ayoka.databinding.FragmentBaseRecyclerviewBinding;
import com.ayoka.mvp.CollectionMVP;
import com.jcp.baselibrary.brvah.BaseQuickAdapter;
import com.jcp.baselibrary.brvah.BaseViewHolder;
import com.jcp.baselibrary.brvah.RecycleViewDivider;

/**
 * Created by admin on 2017/3/20.
 */

public class CollectionMeditationFragment extends BaseRecyclerViewFragment<String, FragmentBaseRecyclerviewBinding, CollectionMVP.CollectionPresenter> implements CollectionMVP.ICollectionView{


    public static CollectionMeditationFragment newInstance() {
        CollectionMeditationFragment meditationCollectionFragment = new CollectionMeditationFragment();
        return meditationCollectionFragment;
    }

    @Override
    protected SwipeRefreshLayout getRefreshLayout() {
        return mDataBinding.swipeRefresh;
    }

    @Override
    protected RecyclerView getRecyclerView() {
        return mDataBinding.recyclerView;
    }

    @Override
    protected int getContentLayout() {
        return R.layout.fragment_base_recyclerview;
    }

    @Override
    public void initData() {
        getData(true);
    }

    @Override
    protected CollectionMVP.CollectionPresenter getPresenter() {
        return new CollectionMVP.CollectionPresenter();
    }


    @Override
    protected BaseQuickAdapter<String, BaseViewHolder> getAdapter() {
        MeditationCollectionAdapter adapter = new MeditationCollectionAdapter();
        adapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
            @Override
            public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
                if (view.getId() == R.id.tv_play){

                }
            }
        });
        return adapter;
    }

    @Override
    protected RecyclerView.ItemDecoration getRecycleDivider() {
        return RecycleViewDivider.getLineDivider(getActivity());
    }

    @Override
    protected void getData(boolean isShowWaitDialog) {
        mPresenter.getMeditationCollectionListData(isShowWaitDialog, pageNo, pageSize);
    }

    @Override
    public void configCollectionListData(PagerBean data) {
        if (data == null){
            setSwipeRefreshLoadedState();
            return;
        }
        setLoadMoreLayout(data.list);
    }
}
